/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Radiostation_POJOS;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Nikos
 */
@Entity
@Table(name = "ALBUM")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Album.findAll", query = "SELECT a FROM Album a"),
    @NamedQuery(name = "Album.findByAlbumId", query = "SELECT a FROM Album a WHERE a.albumId = :albumId"),
    @NamedQuery(name = "Album.findByTitle", query = "SELECT a FROM Album a WHERE a.title = :title"),
    @NamedQuery(name = "Album.findByReleasedate", query = "SELECT a FROM Album a WHERE a.releasedate = :releasedate"),
    @NamedQuery(name = "Album.findByType", query = "SELECT a FROM Album a WHERE a.type = :type"),
    @NamedQuery(name = "Album.findByDiscnumber", query = "SELECT a FROM Album a WHERE a.discnumber = :discnumber")})
public class Album implements Serializable {
    @Basic(optional = false)
    @Column(name = "DISCNUMBER")
    private String discnumber;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "albumId")
    private Collection<Song> songCollection;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ALBUM_ID")
    private Integer albumId;
    @Basic(optional = false)
    @Column(name = "TITLE")
    private String title;
    @Basic(optional = false)
    @Column(name = "RELEASEDATE")
    private String releasedate;
    @Basic(optional = false)
    @Column(name = "TYPE")
    private String type;
    @JoinTable(name = "ALBUM_SONGS", joinColumns = {
        @JoinColumn(name = "ALBUM", referencedColumnName = "ALBUM_ID")}, inverseJoinColumns = {
        @JoinColumn(name = "SONG", referencedColumnName = "SONG_ID")})
    @ManyToMany
    private List<Song> songList;
    @JoinColumn(name = "ARTIST", referencedColumnName = "ARTIST_ID")
    @ManyToOne
    private Artist artist;
    @JoinColumn(name = "MUSICGROUP", referencedColumnName = "MUSICGROUP_ID")
    @ManyToOne
    private Musicgroup musicgroup;
    @JoinColumn(name = "MUSICPRODUCTIONCOMPANYNAME", referencedColumnName = "NAME")
    @ManyToOne(optional = false)
    private Musicproductioncompany musicproductioncompanyname;

    public Album() {
    }

    public Album(Integer albumId) {
        this.albumId = albumId;
    }

    public Album(Integer albumId, String title, String releasedate, String type) {
        this.albumId = albumId;
        this.title = title;
        this.releasedate = releasedate;
        this.type = type;
    }

    public Integer getAlbumId() {
        return albumId;
    }

    public void setAlbumId(Integer albumId) {
        this.albumId = albumId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getReleasedate() {
        return releasedate;
    }

    public void setReleasedate(String releasedate) {
        this.releasedate = releasedate;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }


    @XmlTransient
    public List<Song> getSongList() {
        return songList;
    }

    public void setSongList(List<Song> songList) {
        this.songList = songList;
    }

    public Artist getArtist() {
        return artist;
    }

    public void setArtist(Artist artist) {
        this.artist = artist;
    }

    public Musicgroup getMusicgroup() {
        return musicgroup;
    }

    public void setMusicgroup(Musicgroup musicgroup) {
        this.musicgroup = musicgroup;
    }

    public Musicproductioncompany getMusicproductioncompanyname() {
        return musicproductioncompanyname;
    }

    public void setMusicproductioncompanyname(Musicproductioncompany musicproductioncompanyname) {
        this.musicproductioncompanyname = musicproductioncompanyname;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (albumId != null ? albumId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Album)) {
            return false;
        }
        Album other = (Album) object;
        if ((this.albumId == null && other.albumId != null) || (this.albumId != null && !this.albumId.equals(other.albumId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Radiostation_POJOS.Album[ albumId=" + albumId + " ]";
    }


    @XmlTransient
    public Collection<Song> getSongCollection() {
        return songCollection;
    }

    public void setSongCollection(Collection<Song> songCollection) {
        this.songCollection = songCollection;
    }

    public String getDiscnumber() {
        return discnumber;
    }

    public void setDiscnumber(String discnumber) {
        this.discnumber = discnumber;
    }
    
}
